//
//  YYAccountSafeViewController.swift
//  STMusic
//
//  Created by stoneobs on 2017/6/21.
//  Copyright © 2017年 stoneobs. All rights reserved.
////**********************账号与安全***************************

import UIKit

class YYAccountSafeViewController: STTableViewController {
    
    let datasouceArray = ["当前账号","碎月账号","修改密码"];
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "账号与安全";

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // MARK: UITableView DataSouce
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1;
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return datasouceArray.count;
    }
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44;
    }
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10;
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell");
        if cell == nil {
            cell = UITableViewCell.init(style: .value1, reuseIdentifier: "cell");
        }
        cell?.textLabel?.text = datasouceArray[indexPath.row];
        cell?.textLabel?.font = Font15;
        cell?.detailTextLabel?.font = Font13;
        cell?.textLabel?.textColor = FirstTextColor;
        if indexPath.row == 0 {
            cell?.accessoryView = UIView();
            cell?.detailTextLabel?.text = YYUserLoginedDefultManger.shared().currentUser().mobilePhoneNumber;
        }
        if indexPath.row == 1 {
            cell?.accessoryType = .disclosureIndicator;
            cell?.detailTextLabel?.text = "未绑定";
            cell?.detailTextLabel?.textColor = UIColor.flatMint;
            if YYUserLoginedDefultManger.shared().currentUser().suiyueAccount != "" {
                cell?.detailTextLabel?.text = YYUserLoginedDefultManger.shared().currentUser().suiyueAccount;
                cell?.detailTextLabel?.textColor = SecendTextColor;
            }
        }
        if indexPath.row == 2 {
            cell?.accessoryType = .disclosureIndicator;
    
        }
        return cell!;
    }
    
    // MARK: UITableView Delegate
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: false);
        
        if indexPath.row == 2 {
            //修改改密码
            self.navigationController?.pushViewController(YYChangePwdViewController(), animated: true);
        }
        
    }

}
